const { createProxyMiddleware } = require("http-proxy-middleware");

module.exports = function (app) {
  app.use(
    createProxyMiddleware("/cnpc-web/chat-tool-chat", {
      // target: "http://10.51.1.31:31501/supgpt-app/chat-tool-chat",
      target: "http://litetpt.supcon5t.com:31501/supgpt-app/chat-tool-chat",
      // target: "https://supcontpt.supcon.com/supgpt-app/chat-tool-chat",
      // target:'http://10.18.1.78:31501/cnpc-web/chat-tool-chat',
      changeOrigin: true,
      pathRewrite: { "^/cnpc-web/chat-tool-chat": "" },
    }),
    createProxyMiddleware("/cnpc-web/chat-tool-app/", {
      // target: "http://10.51.1.31:31501/supgpt-app/chat-tool-chat/api/",
      target: "http://litetpt.supcon5t.com:31501/supgpt-app/chat-tool-app/",
      // target: "https://supcontpt.supcon.com/supgpt-app/chat-tool-app/",
      // target: "http://10.18.1.78:31501/cnpc-web/chat-tool-app/",
      changeOrigin: true,
      pathRewrite: { "^/cnpc-web/chat-tool-app/": "" },
    }),
    createProxyMiddleware("/cnpc-web/supgpt-app/chat-tool-voice-speak", {
      target: "ws://10.16.11.21:8010",
      changeOrigin: true,
      ws: true,
      pathRewrite: { "^/cnpc-web/supgpt-app/chat-tool-voice-speak": "" },
    }),
    createProxyMiddleware("/cnpc-web/supgpt-app/chat-tool-voice-ident", {
      target: "ws://10.16.11.25:8006/",
      changeOrigin: true,
      ws: true,
      pathRewrite: { "^/cnpc-web/supgpt-app/chat-tool-voice-ident": "" },
    }),
    createProxyMiddleware("/cnpc-web/customized-service-websocket", {
      target: "ws://litetpt.supcon5t.com:31723/customized-service",
      changeOrigin: true,
      ws: true,
      pathRewrite: {
        "^/cnpc-web/customized-service-websocket": "",
      },
    }),
    createProxyMiddleware("/cnpc-web/supgpt-app/auto-supervision", {
      //target: "http://10.30.71.102:8082",
      target:
        "http://litetpt.supcon5t.com:31501/cnpc-web/supgpt-app/auto-supervision",
      changeOrigin: true,
      ws: true,
      pathRewrite: { "^/cnpc-web/supgpt-app/auto-supervision": "" },
    }),
    createProxyMiddleware("/cnpc-web/supgpt-app/param", {
      target: "http://10.30.71.48:31234",
      // target: "http://10.18.1.78:31501/cnpc-web/supgpt-app/param",
      // target: "http://10.18.1.78:31501/cnpc-web/supgpt-app/param",
      // target: "http://litetpt.supcon5t.com:31501/cnpc-web/supgpt-app/param",
      changeOrigin: true,
      ws: true,
      pathRewrite: { "^/cnpc-web/supgpt-app/param": "" },
    }),

    createProxyMiddleware("/cnpc-web/voice/websocket", {
      target: "ws://10.18.1.78:32601/tuling/ast/v2",
      changeOrigin: true,
      ws: true,
      pathRewrite: { "^/cnpc-web/voice/websocket": "" },
    })
  );
};
